package top.frsf.tank;

import top.frsf.GamePanel;

import java.awt.event.KeyEvent;

/**
 * @BelongsProject: TankWar1
 * @BelongsPackage: top.frsf.tank
 * @Author: FRSF
 * @CreateTime: 2022-09-04  22:45
 * @Description: 玩家二
 * @Version: 1.0
 */
public class PlayerTwo extends PlayerOne {

    public PlayerTwo(String img, int x, int y, GamePanel gamePanel, String upImage, String downImage, String leftImage, String rightImage) {
        super(img, x, y, gamePanel, upImage, downImage, leftImage, rightImage);
    }

    @Override
    public void keyPressed(KeyEvent e) {
        int key = e.getKeyCode();
        switch (key) {
            case KeyEvent.VK_UP:
                up = true;
                break;
            case KeyEvent.VK_DOWN:
                down = true;
                break;
            case KeyEvent.VK_LEFT:
                left = true;
                break;
            case KeyEvent.VK_RIGHT:
                right = true;
                break;
            case KeyEvent.VK_NUMPAD0:
                attack();
                break;
        }
    }

    @Override
    public void keyReleased(KeyEvent e) {
        int key = e.getKeyCode();
        switch (key) {
            case KeyEvent.VK_UP:
                up = false;
                break;
            case KeyEvent.VK_DOWN:
                down = false;
                break;
            case KeyEvent.VK_LEFT:
                left = false;
                break;
            case KeyEvent.VK_RIGHT:
                right = false;
                break;
        }
    }
}
